<?php

require_once('lib/gymnasium.php');
require_once('lib/gymhours.php');
$is_admin = $_SESSION['status_code'] == 'ADMIN';
?>
<h3>Horaires</h3>


<table class="dataTable">
	<thead>
	<tr>
		<th>Catégorie</th>
		<?php
		$gyms = gym_get_list();
		while ($row = mysql_fetch_assoc($gyms)) {
			echo '<th>'.$row['name'].'</th>';
		}
		?>
	</tr>
	</thead>
	<tbody>
	<?php
	$hours = hours_get_list();
	foreach ($hours as $hour) {
		echo '
		<tr>
			<td>
				<a href="?p=club&amp;r=categories_edit&amp;id='.$hour[0].'" class="right" title="Modifier la catégorie">'.icon_tag('pencil').'</a>
				<strong>'.$hour[1].'</strong><br />
				<em>Age</em> : '.$hour[2].'<br />
				<em>Places max</em> : '.($hour[4] ? $hour[4] : 'Non indiqué').'
			</td>';
			for ($i = 5; $i < count($hour); $i += 2) {
				echo '<td>';
				if ($is_admin) {
					echo '<a href="?p=club&amp;r=hours_edit&amp;gym_id='.$hour[$i].'&amp;cat_id='.$hour[0].'" title="Modifier l\'horaire" class="right"> '.icon_tag('pencil').'</a>';
				}
				
				if ($hour[$i + 1]) {
					echo $hour[$i + 1];
				}
				else {
					echo '<em style="color: red;">créneau fermé</em>';
				}
				echo '</td>';
			}
		echo '
		</tr>';
	}
	?>
	</tbody>
</table>
